package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.entity.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;
    @PostMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        userService.updateUser(user);
    }

    @RequestMapping("addUser")
    public void addUser(@RequestBody User user){

        userService.addUser(user);
    }

    @RequestMapping("/deleteUser")
    public void deleteUser(Integer id){userService.deleteUser(id);}
    @RequestMapping("findAll")
    public IPage<User> findAll(@RequestParam(defaultValue = "1") int pageNum,
                               @RequestParam(defaultValue = "3") int pageSize){
        return userService.pageFindAll(pageNum,pageSize);
    }
}
